import request from '@/utils/request'
enum API{
    reqProductList='/admin/product/',
    addSpu='/admin/product/saveSpuInfo',
    updateSpu='/admin/product/updateSpuInfo',
    deleteSpu='/admin/product/deleteSpu/',
    reqSkuList='/admin/product/findBySpuId/',
    reqBaseValueList='/admin/product/getSpuById/',
    allSaleAttr='/admin/product/baseSaleAttrList',
    allTradeMark='/admin/product/baseTrademark/getTrademarkList',
    imgList='/admin/product/spuImageList/',
    addSku='/admin/product/saveSkuInfo',
    reqPlatForm='/admin/product/attrInfoList/',
    reqSaleAttr='/admin/product/spuSaleAttrList/',
    reqSaveSku='/admin/product/saveSkuInfo'

}
// 获取spu列表
export const reqProductList=(page:number,limit:number,category3Id:number|string)=>request.get(API.reqProductList+`${page}/${limit}?category3Id=${category3Id}`)
//添加修改两用 接口 
export const reqAddOrUpdateSpu=(data:any)=>{
    if(data.id){
        return request.post(API.updateSpu,data)
    }else{
        return request.post(API.addSpu,data)
    }
}
// 删除spu
export const reqDeleteSpu=(id:number)=>request.delete(API.deleteSpu+`${id}`)
// 获取sku列表
export const reqSkuList=(spuId:number)=>request.get(API.reqSkuList+`${spuId}`)
// 获取spu的销售基本属性
export const reqBaseValueList=(spuId:number)=>request.get(API.reqBaseValueList+`${spuId}`)
//获取全部销售属性
export  const reqAllSaleAttr=()=>request.get(API.allSaleAttr)
// 获取全部照片墙列表
export const reqImgList=(spuId:number)=>request.get(API.imgList+`${spuId}`)
// 获取所有品牌
export const reqAllTradeMark=()=>request.get(API.allTradeMark)
// 获取平台属性
export const reqPlatForm=(category1Id:string|number,category2Id:string|number,category3Id:string|number)=>request.get(API.reqPlatForm+`${category1Id}/${category2Id}/${category3Id}`)
// 添加SKU接口
export const addSku=(data:any)=>request.post(API.addSku,data)
// 获取已有的销售属性
export const reqSaleAttr=(spuId:number)=>request.get(API.reqSaleAttr+`${spuId}`)
//添加Sku
export const reqSaveSKu=(data:any)=>request.post(API.reqSaveSku,data)


 